/**
 * 
 */
package com.dalonedrow.rpg.base.systems;

import com.dalonedrow.engine.sprite.base.SimpleVector3;

/**
 * @author Donald
 */
public interface Spells<IO, SPELL> {
	void abortSpellSound();
	/**
	 * Adds a spell effect to the spell's caster.
	 * @param caster the caster's id
	 * @param spell the spell id
	 * @throws Exception if an error occurs
	 */
	void addSpellOn(final int caster, final int spell) throws Exception;
	void analyze();
	float applyColdProtection(IO io, float damages);
	float applyFireProtection(IO io, float damages);
	/**
	 * Cancels all spells associated with the PC.
	 * @throws Exception if an error occurs
	 */
	void cancelAll() throws Exception;
	void cancelSpellTarget();
	/**
	 * Determines if the spell caster can pay the mana cost for the attempted 
	 * spell.
	 * @param num the spell number
	 * @param cost the cost
	 * @param playSound flag indicating a sound needs to be played when the
	 * caster cannot pay the spell cost
	 * @return <code>boolean</code>
	 * @throws Exception if an error occurs
	 */
	boolean canPayMana(int num, float cost, boolean playSound) throws Exception;
	void clearAll() throws Exception;
	void clearParticles();
	boolean existAnyInstance(int typ);
	boolean existAnyInstanceForThisCaster(int typ, int caster);
	void fizzle(int num);
	void fizzleAllSpellsFromCaster(int num_caster);
	void fizzleNoMana(int num);
	int getFree();
	long getInstance(int typ);
	long getInstanceForThisCaster(int typ, int caster);
	float getManaCost(long _lNumSpell, long lNumSpellTab);
	SPELL getSpell(int index);
	/**
	 * Gets the spell reference type for the spell name.  If the name isn't 
	 * valid, -1 is returned.
	 * @param spell the spell name
	 * @return <code>int</code>
	 */
	int getSpellId(char[] spell);
	/**
	 * Gets the spell reference type for the spell name.  If the name isn't 
	 * valid, -1 is returned.
	 * @param spell the spell name
	 * @return <code>int</code>
	 */
	int getSpellId(String spell);
	/**
	 * Gets the reference id of a spell that exists on the interactive
	 * object.  If the IO does not have the specific spell on it, then -1 is
	 * returned.
	 * @param io the IO
	 * @param spellType the spell type
	 * @return <code>int</code>
	 */
	int getSpellOn(IO io, int spellType);
	void init();
	void initKnownSpells();
	void kill(int i);
	long launchSpell(int typ, int source, int flags, int level, int target,
			long timeDuration, int turnDuration);
	void launchSpellTarget(IO io);
	/**
	 * Gets the spell's name. 
	 * @param type the spell's type
	 * @return {@link String]
	 * @throws Exception if the spell id isn't valid
	 */
	String makeSpellName(int type) throws Exception;
	void manageMagic(IO io);
	boolean noMagicAllowed();
	void precastAdd(long typ, long _level, long flags, long duration);
	void precastCheck();
	long precastCheckCanPayMana(long num, float cost, boolean _bSound);
	void precastLaunch(long num);
	void precastReset();
	/**
	 * Removes all spells from an interactive object.
	 * @param io the IO
	 */
	void removeAllSpellsOn(IO io);
	/**
	 * Removes the spell from all interactive objects.
	 * @param spell the spell reference id
	 * @throws Exception if an error occurs
	 */
	void removeMultiSpellOn(int spell) throws Exception;
	/**
	 * Removes a spell from an interactive object.
	 * @param caster the IO reference id
	 * @param spell the spell reference id
	 * @throws Exception if an error occurs
	 */
	void removeSpellOn(int caster, int spell) throws Exception;
	void resetRecognition();
	void spellCastNotify(long num);
	void spellCastNotifyOnlyTarget(long num);
	void spellEndNotify(long num);
	boolean TemporaryGetSpellTarget(SimpleVector3 from);
	void tryToCastSpell(IO io, int spellid, int level,
			int target, int flags, long duration);
	void update();
	void updateLightning();

}
